---@class WenheYanbing.RoomBase : Base.RoomBase
---@field public phase string
---@field public turn integer
---@field public roundTime integer
---@field public engine WenheYanbing.Engine
local RoomBase = Fk.Base.RoomBase:subclass("WenheYanbing.RoomBase")

function RoomBase:initialize()
    Fk.Base.RoomBase.initialize(self)
    
    self.phase = "recruit"
    self.turn = 1
    self.roundTime = 60
    
    -- 获取引擎实例
    self.engine = require("packages.wenhe_yanbing.wenhe_yanbing")
end

-- 序列化用于全量同步
function RoomBase:serialize()
    local o = Fk.Base.RoomBase.serialize(self)
    o.phase = self.phase
    o.turn = self.turn
    o.roundTime = self.roundTime
    return o
end

function RoomBase:deserialize(o)
    Fk.Base.RoomBase.deserialize(self, o)
    self.phase = o.phase
    self.turn = o.turn
    self.roundTime = o.roundTime
end

-- 切换游戏阶段
function RoomBase:setPhase(newPhase)
    if self.phase ~= newPhase then
        self.phase = newPhase
        self:doBroadcastNotify("UpdatePhase", {
            phase = newPhase,
            turn = self.turn
        })
    end
end

return RoomBase